<?php

namespace App\Http\Controllers\Game\Config;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Http\Resources\Common\DatasResource;
use App\Http\Resources\Common\DataResource;
use App\Services\Game\Config\CurrencyService;
use App\Models\Game\Config\Currency;

class CurrencyController extends Controller
{

    /**
     * 获取数据列表
     */
    public function getList(Request $request)
    {
        list ($collection, $total) = CurrencyService::make()->getList($request);

        return DatasResource::make($collection)->setPaginateTotal($total);
    }

    /**
     * 刷新数据
     */
    public function refresh(Request $request)
    {
        $id = $request->input('id');

        $model = Currency::findOrFail($id);
        // 通知游戏端配置修改
        $model->syncGameService();

        return new DataResource($model);
    }
}
